<!DOCTYPE html>
<html lang="en-US">
    <head>
        <title>File::Tail - Perl extension for reading from continously updated files - metacpan.org</title>
        <link rel="preload" as="fetch" href="https://metacpan.org/account/login_status" crossorigin="anonymous" />
        <link href="https://metacpan.org/_assets/b8ccceeed47a0652049703d99326a9cea4933443.css" rel="stylesheet" type="text/css">
        <script src="https://metacpan.org/_assets/6bfedafe2d7caa915b7d84f61b45936818e3242e.js" type="text/javascript" defer></script>
        <link rel="alternate" type="application/rss+xml" title="Recent CPAN Uploads of File-Tail - MetaCPAN" href="https://metacpan.org/dist/File-Tail/releases.rss" />
        <link rel="canonical" href="./File::Tail.html" />
        <meta name="description" content="Perl extension for reading from continously updated files" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5">
        <link rel="shortcut icon" href="https://metacpan.org/static/icons/favicon.ico">
        <link rel="apple-touch-icon" sizes="152x152" href="https://metacpan.org/static/icons/apple-touch-icon.png">
        <link rel="search" href="https://metacpan.org/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN">
        <script>
          (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
          (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

          (function(skey, ga_id){
            ga('create', ga_id, {
              siteSpeedSampleRate : 100,
              storage             : 'none',
              clientId            : localStorage.getItem(skey)
            });
            ga(function(tracker) {
              localStorage.setItem(skey, tracker.get('clientId'));
            });
            ga('send', 'pageview');
          })('ga:clientId', 'UA-27829474-1');
        </script>
<meta name="twitter:card"        content="summary" />
<meta name="twitter:url"         content="https://metacpan.org/pod/File::Tail" />
<meta name="twitter:title"       content="File::Tail" />
<meta name="twitter:description" content="Perl extension for reading from continously updated files" />
<meta name="twitter:site"        content="metacpan" />
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="header-logo-large hidden-xs">
              <a href="https://metacpan.org/" tabindex="0">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#logo" />
                </svg>
              </a>
            </div>
            <div class="header-logo-icon visible-xs">
              <a href="https://metacpan.org/">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#dots" />
                </svg>
              </a>
            </div>
            <ul class="nav navbar-nav menu-items hidden-xs hidden-sm">
              <li><a href="https://metacpan.org/about">About</a></li>
              <li><a href="https://metacpan.org/about/sponsors">Sponsor</a></li>
              <li><a href="https://grep.metacpan.org/">grep::cpan</a></li>
              <li><a href="https://metacpan.org/recent">Recent</a></li>
              <li><a href="https://metacpan.org/about/faq">FAQ</a></li>
              <li><a href="https://metacpan.org/tools">Tools</a></li>
              <li><a href="https://fastapi.metacpan.org/">API</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <button type="button" class="searchbar-btn visible-xs visible-sm">
                    <i class="fa fa-search button-fa-icon"></i>
                </button>
                <form action="https://metacpan.org/search" class="searchbar-form visible-md visible-lg search-form form-horizontal">
                   <input type="hidden" name="size" id="metacpan_search-size" value="20">
                  <div class="form-group">
                      <div class="search-group">
                        <i class="fa fa-search"></i>
                        <input type="text" name="q" placeholder="Search the CPAN" size="41" autocorrect="off" autocapitalize="off" spellcheck="false" id="metacpan_search-input" class="form-control" value="">
                      </div>
                  </div>
                </form>
                    <li class="icon-slidepanel visible-xs visible-sm">
                      <button data-toggle="slidepanel" data-target=".slidepanel">
                        <span class="button-fa-icon">
                          <i class="fa fa-bars slidepanel-open"></i>
                          <i class="fa fa-times slidepanel-close"></i>
                        </span>
                      </button>
                    </li>
                <form action="https://metacpan.org/account/logout" method="POST" id="metacpan-logout"></form>
                <li class="dropdown logged_in" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon logged-in-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="https://metacpan.org/account/identities">Identities</a></li>
                        <li><a href="https://metacpan.org/account/profile">Profile</a></li>
                        <li><a href="https://metacpan.org/account/favorite/list">Favorites</a></li>
                        <li>
                            <a href="./File::Tail.html#" type="button" onclick="$('#metacpan-logout').submit(); return false">
                              Logout
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_out" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li>
                            <a href="https://metacpan.org/login/github">
                                <i class="fab fa-github fa-fw"></i>
                                GitHub
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/twitter">
                                <i class="fab fa-twitter fa-fw"></i>
                                Twitter
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/google">
                                <i class="fab fa-google fa-fw"></i>
                                Google
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_placeholder">
                    <button>
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                    </button>
                </li>
            </ul>
        </nav>
        <div class="page-content ">
          <!--
          <div class="top-notify-banner">
            <i class="fas fa-info-circle"></i>
          </div>
          -->
          <nav class="sidebar">
            <div class="slidepanel">
              <ul class="nav-list ">
    <li class="nav-header no-margin-top">
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The date that this version of File-Tail was released.">
      <span class="relatize">02 Aug 2015 14:23:35 UTC</span>
    </li>
  <li>
    Distribution: <a href="https://metacpan.org/dist/File-Tail">File-Tail</a>
  </li>
  <li>
    Module version: 1.3
  </li>
  <li>
    <a data-keyboard-shortcut="g s" href="https://metacpan.org/dist/File-Tail/source/Tail.pm">Source</a>
    (<a href="https://metacpan.org/dist/File-Tail/source/Tail.pm?raw=1">raw</a>)
  </li>
  <li>
    <a data-keyboard-shortcut="g b" href="https://metacpan.org/dist/File-Tail/source">Browse</a>
    (<a href="https://metacpan.org/dist/File-Tail/source?raw=1">raw</a>)
  </li>
    <li>
      <a data-keyboard-shortcut="g c" href="https://metacpan.org/dist/File-Tail/changes">Changes</a>
    </li>
    <li>
      <a class="nopopup" href="https://metacpan.org/dist/File-Tail/contribute">How to Contribute</a>
    </li>
    <li>
      <a rel="noopener nofollow" data-keyboard-shortcut="g i" href="https://rt.cpan.org/Public/Dist/Display.html?Name=File-Tail">Issues</a>
      (22)
    </li>
    <li>
      <a rel="noopener nofollow" href="http://matrix.cpantesters.org/?dist=File-Tail+1.3" title="Matrix">Testers</a>
        <span title="(pass / fail / na)">(<a rel="noopener nofollow" href="https://www.cpantesters.org/distro/F/File-Tail.html?oncpan=1&amp;distmat=1&amp;version=1.3&amp;grade=2" style="color: #090">262</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/F/File-Tail.html?oncpan=1&amp;distmat=1&amp;version=1.3&amp;grade=3" style="color: #900">0</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/F/File-Tail.html?oncpan=1&amp;distmat=1&amp;version=1.3&amp;grade=4">0</a>)</span>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpants.cpanauthors.org/release/MGRABNAR/File-Tail-1.3">Kwalitee</a>
    </li>
    <li>
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The # people with an indexing permission on File-Tail who have released something to CPAN in the last 2 years (i.e. the # people likely able to release critical fixes in a timely manner)">
      Bus factor: 0
      </div>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpancover.com/latest/File-Tail-1.3/index.html">57.64% Coverage </a>
    </li>
    <li>
      License: perl_5
    </li>
    <li class="nav-header">Activity</li>
    <li>
<div class="activity-graph">
    <img src="https://metacpan.org/dist/File-Tail/activity.svg?res=month" />
    <div class="comment">24 month</div>
</div>
    </li>
    <li class="nav-header">Tools</li>
    <li>
      <a itemprop="downloadUrl" href="https://cpan.metacpan.org/authors/id/M/MG/MGRABNAR/File-Tail-1.3.tar.gz">
      Download (<span itemprop="fileSize">23.84KB</span>)</a>
    </li>
    <li>
      <a href="https://explorer.metacpan.org/?url=%2Fmodule%2FMGRABNAR%2FFile-Tail-1.3%2FTail.pm">
        MetaCPAN Explorer
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/File-Tail/permissions">
        Permissions
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/File-Tail/releases.rss">
        Subscribe to distribution
      </a>
    </li>
    <li>
      <button class="btn btn-link" data-toggle="modal" data-target="#metacpan_install-instructions-dialog">
        Install Instructions
      </button>
    </li>
    <li>
      <form action="https://metacpan.org/search">
        <input type="hidden" name="q" value="dist:File-Tail">
        <input type="search" name="q" placeholder="Search distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
      </form>
    </li>
    <li>
      <form action="https://grep.metacpan.org/search">
        <input type="hidden" name="qd" value="File-Tail">
        <input type="hidden" name="source" value="metacpan">
        <input type="search" name="q" placeholder="grep distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
     </form>
    </li>
    <li class="version-jump">
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/Tail.pm&#39;" class="form-control tool-bar-form">
  <option disabled selected>Jump to version</option>
<option
  disabled
  value="MGRABNAR/File-Tail-1.3"
>1.3
  (MGRABNAR on 2015-08-02)</option>
<option
  
  value="MGRABNAR/File-Tail-1.2"
>1.2
  (MGRABNAR on 2015-04-21)</option>
<option
  
  value="MGRABNAR/File-Tail-1.1"
>1.1
  (MGRABNAR on 2015-04-18)</option>
<option
  
  value="MGRABNAR/File-Tail-1.0"
>1.0
  (MGRABNAR on 2014-12-03)</option>
<option
  
  value="MGRABNAR/File-Tail-0.99.3"
>0.99.3
  (MGRABNAR on 2005-09-14)</option>
<optgroup label="BackPAN">'
<option
  
  value="MGRABNAR/File-Tail-0.99.2"
>0.99.2
  (MGRABNAR on 2005-09-14)</option>
<option
  
  value="MGRABNAR/File-Tail-0.99.1"
>0.99.1
  (MGRABNAR on 2004-12-01)</option>
<option
  
  value="MGRABNAR/File-Tail-0.98"
>0.98
  (MGRABNAR on 2000-12-27)</option>
<option
  
  value="MGRABNAR/File-Tail-0.97"
>0.97
  (MGRABNAR on 2000-10-03)</option>
<option
  
  value="MGRABNAR/File-Tail-0.96"
>0.96
  (MGRABNAR on 2000-08-14)</option>
<option
  
  value="MGRABNAR/File-Tail-0.95"
>0.95
  (MGRABNAR on 1999-12-09)</option>
<option
  
  value="MGRABNAR/File-Tail-0.94"
>0.94
  (MGRABNAR on 1999-11-17)</option>
<option
  
  value="MGRABNAR/File-Tail-0.91"
>0.91
  (MGRABNAR on 1999-02-02)</option>
<option
  
  value="MGRABNAR/File-Tail-0.90"
>0.90
  (MGRABNAR on 1999-01-15)</option>
<option
  
  value="MGRABNAR/File-Tail-0.85"
>0.85
  (MGRABNAR on 1998-10-28)</option>
<option
  
  value="MGRABNAR/File-Tail-0.81"
>0.81
  (MGRABNAR on 1998-10-15)</option>
<option
  
  value="MGRABNAR/File-Tail-0.80"
>0.80
  (MGRABNAR on 1998-10-14)</option>
<option
  
  value="MGRABNAR/File-Tail-0.70"
>0.70
  (MGRABNAR on 1998-08-13)</option>
<option
  
  value="MGRABNAR/File-Tail-0.7"
>0.7
  (MGRABNAR on 1998-08-13)</option>
</optgroup>
</select>
    </li>
    <li class="version-diff">
<select onchange="document.location.href='/release/MGRABNAR/File-Tail-1.3/diff/' + encodeURIComponent(this.value) + '/Tail.pm'
" class="form-control tool-bar-form">
  <option disabled selected>Diff with version</option>
<option
  disabled
  value="MGRABNAR/File-Tail-1.3"
>1.3
  (MGRABNAR on 2015-08-02)</option>
<option
  
  value="MGRABNAR/File-Tail-1.2"
>1.2
  (MGRABNAR on 2015-04-21)</option>
<option
  
  value="MGRABNAR/File-Tail-1.1"
>1.1
  (MGRABNAR on 2015-04-18)</option>
<option
  
  value="MGRABNAR/File-Tail-1.0"
>1.0
  (MGRABNAR on 2014-12-03)</option>
<option
  
  value="MGRABNAR/File-Tail-0.99.3"
>0.99.3
  (MGRABNAR on 2005-09-14)</option>
<optgroup label="BackPAN">'
<option
  
  value="MGRABNAR/File-Tail-0.99.2"
>0.99.2
  (MGRABNAR on 2005-09-14)</option>
<option
  
  value="MGRABNAR/File-Tail-0.99.1"
>0.99.1
  (MGRABNAR on 2004-12-01)</option>
<option
  
  value="MGRABNAR/File-Tail-0.98"
>0.98
  (MGRABNAR on 2000-12-27)</option>
<option
  
  value="MGRABNAR/File-Tail-0.97"
>0.97
  (MGRABNAR on 2000-10-03)</option>
<option
  
  value="MGRABNAR/File-Tail-0.96"
>0.96
  (MGRABNAR on 2000-08-14)</option>
<option
  
  value="MGRABNAR/File-Tail-0.95"
>0.95
  (MGRABNAR on 1999-12-09)</option>
<option
  
  value="MGRABNAR/File-Tail-0.94"
>0.94
  (MGRABNAR on 1999-11-17)</option>
<option
  
  value="MGRABNAR/File-Tail-0.91"
>0.91
  (MGRABNAR on 1999-02-02)</option>
<option
  
  value="MGRABNAR/File-Tail-0.90"
>0.90
  (MGRABNAR on 1999-01-15)</option>
<option
  
  value="MGRABNAR/File-Tail-0.85"
>0.85
  (MGRABNAR on 1998-10-28)</option>
<option
  
  value="MGRABNAR/File-Tail-0.81"
>0.81
  (MGRABNAR on 1998-10-15)</option>
<option
  
  value="MGRABNAR/File-Tail-0.80"
>0.80
  (MGRABNAR on 1998-10-14)</option>
<option
  
  value="MGRABNAR/File-Tail-0.70"
>0.70
  (MGRABNAR on 1998-08-13)</option>
<option
  
  value="MGRABNAR/File-Tail-0.7"
>0.7
  (MGRABNAR on 1998-08-13)</option>
</optgroup>
</select>
    </li>

    <li>
<ul class="dependencies">
  <li class="nav-header">Dependencies</li>
  <li><a href="https://metacpan.org/pod/File::stat" title="File::stat" class="ellipsis">File::stat</a></li>
  <li><a href="https://metacpan.org/pod/FileHandle" title="FileHandle" class="ellipsis">FileHandle</a></li>
  <li><a href="https://metacpan.org/pod/IO::Seekable" title="IO::Seekable" class="ellipsis">IO::Seekable</a></li>
  <li><a href="https://metacpan.org/pod/Time::HiRes" title="Time::HiRes" class="ellipsis">Time::HiRes</a></li>
  <li><i class="ttip" title="dynamic_config enabled">and possibly others</i></li>
  <li>
    <hr>
  </li>
  <li>
    <a href="https://metacpan.org/module/File::Tail/requires">Reverse dependencies</a>
  </li>
  <li>
    <a href="http://deps.cpantesters.org/?module=File%3A%3ATail">CPAN Testers List</a>
  </li>
  <li>
    <a href="https://cpandeps.grinnz.com/?dist=File-Tail">Dependency graph</a>
  </li>
</ul>
    </li>
    <li class="nav-header">Permalinks</li>
    <li>
      <a href="https://metacpan.org/release/MGRABNAR/File-Tail-1.3/view/Tail.pm">This version</a>
    </li>
    <li>
      <a href="./File::Tail.html">Latest version</a>
    </li>
    <li>
<div class="plussers">
<div class="nav-header">++ed by:</div>
<div>
<a class="display-all" href="https://metacpan.org/author/JMATES"><img src="https://www.gravatar.com/avatar/06accb84e6519284be3941ff72e429cb?d=identicon&amp;s=20" title="JMATES" alt="JMATES"></a>
<a class="display-all" href="https://metacpan.org/author/KEEDI"><img src="https://www.gravatar.com/avatar/95f905a7a4ccc573c711e9d264c0fde8?d=identicon&amp;s=20" title="KEEDI" alt="KEEDI"></a>
<a class="display-all" href="https://metacpan.org/author/PAVELSR"><img src="https://www.gravatar.com/avatar/bdd3233525e2a6ca61bbc05752111c15?d=identicon&amp;s=20" title="PAVELSR" alt="PAVELSR"></a>
</div>
<!-- Display counts of plussers-->
<div>
    <a href="https://metacpan.org/dist/File-Tail/plussers">3 PAUSE users</a>
</div>
<div>
    4 non-PAUSE users
</div>
</div>
    </li>
    <li>
    </li>
              </ul>
            </div>
          </nav>
          <div class="content-navigation">
<div class="breadcrumbs">
  <span>
    <a data-keyboard-shortcut="g a" rel="author" href="https://metacpan.org/author/MGRABNAR" class="author-name">Matija Grabnar</a>
  </span>
  <span>&nbsp;/&nbsp;</span>
  <div class="release dist-release status-latest maturity-released">
    <span class="dropdown"><b class="caret"></b></span>
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/Tail.pm&#39;" class="">
<option
  selected
  value="MGRABNAR/File-Tail-1.3"
>1.3
  (MGRABNAR on 2015-08-02)</option>
<option
  
  value="MGRABNAR/File-Tail-1.2"
>1.2
  (MGRABNAR on 2015-04-21)</option>
<option
  
  value="MGRABNAR/File-Tail-1.1"
>1.1
  (MGRABNAR on 2015-04-18)</option>
<option
  
  value="MGRABNAR/File-Tail-1.0"
>1.0
  (MGRABNAR on 2014-12-03)</option>
<option
  
  value="MGRABNAR/File-Tail-0.99.3"
>0.99.3
  (MGRABNAR on 2005-09-14)</option>
<optgroup label="BackPAN">'
<option
  
  value="MGRABNAR/File-Tail-0.99.2"
>0.99.2
  (MGRABNAR on 2005-09-14)</option>
<option
  
  value="MGRABNAR/File-Tail-0.99.1"
>0.99.1
  (MGRABNAR on 2004-12-01)</option>
<option
  
  value="MGRABNAR/File-Tail-0.98"
>0.98
  (MGRABNAR on 2000-12-27)</option>
<option
  
  value="MGRABNAR/File-Tail-0.97"
>0.97
  (MGRABNAR on 2000-10-03)</option>
<option
  
  value="MGRABNAR/File-Tail-0.96"
>0.96
  (MGRABNAR on 2000-08-14)</option>
<option
  
  value="MGRABNAR/File-Tail-0.95"
>0.95
  (MGRABNAR on 1999-12-09)</option>
<option
  
  value="MGRABNAR/File-Tail-0.94"
>0.94
  (MGRABNAR on 1999-11-17)</option>
<option
  
  value="MGRABNAR/File-Tail-0.91"
>0.91
  (MGRABNAR on 1999-02-02)</option>
<option
  
  value="MGRABNAR/File-Tail-0.90"
>0.90
  (MGRABNAR on 1999-01-15)</option>
<option
  
  value="MGRABNAR/File-Tail-0.85"
>0.85
  (MGRABNAR on 1998-10-28)</option>
<option
  
  value="MGRABNAR/File-Tail-0.81"
>0.81
  (MGRABNAR on 1998-10-15)</option>
<option
  
  value="MGRABNAR/File-Tail-0.80"
>0.80
  (MGRABNAR on 1998-10-14)</option>
<option
  
  value="MGRABNAR/File-Tail-0.70"
>0.70
  (MGRABNAR on 1998-08-13)</option>
<option
  
  value="MGRABNAR/File-Tail-0.7"
>0.7
  (MGRABNAR on 1998-08-13)</option>
</optgroup>
</select>
    <a data-keyboard-shortcut="g d" class="release-name" href="https://metacpan.org/dist/File-Tail">File-Tail-1.3</a>
  </div>
<span class="river-gauge-gauge">
  <svg width="24px"
       height="15px"
       version="1.1"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:xlink="http://www.w3.org/1999/xlink">

    <g>
      <title>        River stage two &#10;
          • 9 direct dependents &#10;          • 19 total dependents
      </title>

      <rect x="0"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="5"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="10"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="15"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="20"  y="0" width="4" height="15" fill="#e4e2e2" />
    </g>
  </svg>

</span>
<div id="File-Tail-fav" class="logged_in">
<form action="https://metacpan.org/account/favorite/add" style="display: inline" onsubmit="return favDistribution(this)">
    <input type="hidden" name="remove" value="0">
    <input type="hidden" name="release" value="File-Tail-1.3">
    <input type="hidden" name="author" value="MGRABNAR">
    <input type="hidden" name="distribution" value="File-Tail">
    <button type="submit" class="favorite highlight"><span>7</span> ++</button>
</form>
</div>
<div class="logged_out">
<a href="./File::Tail.html" onclick="alert('Please sign in to add favorites'); return false" class="favorite highlight">
<span>7</span> ++</a>
</div>
   / <span>File::Tail</span>
</div>
          </div>
          <main class="content">


<nav class="toc">
  <div class="toc-header"><strong>Contents</strong></div>
<ul>
  <li><a href="./File::Tail.html#NAME">NAME</a></li>
  <li><a href="./File::Tail.html#SYNOPSIS">SYNOPSIS</a></li>
  <li><a href="./File::Tail.html#DESCRIPTION">DESCRIPTION</a></li>
  <li><a href="./File::Tail.html#CONSTRUCTOR">CONSTRUCTOR</a>
    <ul>
      <li><a href="./File::Tail.html#new-(%5B-ARGS-%5D)">new ([ ARGS ])</a></li>
    </ul>
  </li>
  <li><a href="./File::Tail.html#METHODS">METHODS</a>
    <ul>
      <li><a href="./File::Tail.html#read">read</a></li>
      <li><a href="./File::Tail.html#select">select</a></li>
    </ul>
  </li>
  <li><a href="./File::Tail.html#TO-BE-DONE">TO BE DONE</a></li>
  <li><a href="./File::Tail.html#AUTHOR">AUTHOR</a></li>
  <li><a href="./File::Tail.html#SEE-ALSO">SEE ALSO</a></li>
</ul></nav>
<div class="pod anchors">
<h1 id="NAME">NAME</h1>

<p>File::Tail - Perl extension for reading from continously updated files</p>

<h1 id="SYNOPSIS">SYNOPSIS</h1>

<pre><code>  use File::Tail;
  $file=File::Tail-&gt;new(&quot;/some/log/file&quot;);
  while (defined($line=$file-&gt;read)) {
      print &quot;$line&quot;;
  }

  use File::Tail;
  $file=File::Tail-&gt;new(name=&gt;$name, maxinterval=&gt;300, adjustafter=&gt;7);
  while (defined($line=$file-&gt;read)) {
      print &quot;$line&quot;;
  }</code></pre>

<p>OR, you could use tie (additional parameters can be passed with the name, or can be set using $ref):</p>

<pre><code>    use File::Tail;
    my $ref=tie *FH,&quot;File::Tail&quot;,(name=&gt;$name);
    while (&lt;FH&gt;) {
        print &quot;$_&quot;;
    }</code></pre>

<p>Note that the above script will never exit. If there is nothing being written to the file, it will simply block.</p>

<p>You can find more synopsii in the file logwatch, which is included in the distribution.</p>

<p>Note: Select functionality was added in version 0.9, and it required some reworking of all routines. ***PLEASE*** let me know if you see anything strange happening.</p>

<p>You can find two way of using select in the file select_demo which is included in the ditribution.</p>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p>The primary purpose of File::Tail is reading and analysing log files while they are being written, which is especialy usefull if you are monitoring the logging process with a tool like Tobias Oetiker&#39;s MRTG.</p>

<p>The module tries very hard NOT to &quot;busy-wait&quot; on a file that has little traffic. Any time it reads new data from the file, it counts the number of new lines, and divides that number by the time that passed since data were last written to the file before that. That is considered the average time before new data will be written. When there is no new data to read, <code>File::Tail</code> sleeps for that number of seconds. Thereafter, the waiting time is recomputed dynamicaly. Note that <code>File::Tail</code> never sleeps for more than the number of seconds set by <code>maxinterval</code>.</p>

<p>If the file does not get altered for a while, <code>File::Tail</code> gets suspicious and startschecking if the file was truncated, or moved and recreated. If anything like that had happened, <code>File::Tail</code> will quietly reopen the file, and continue reading. The only way to affect what happens on reopen is by setting the reset_tail parameter (see below). The effect of this is that the scripts need not be aware when the logfiles were rotated, they will just quietly work on.</p>

<p>Note that the sleep and time used are from Time::HiRes, so this module should do the right thing even if the time to sleep is less than one second.</p>

<p>The logwatch script (also included) demonstrates several ways of calling the methods.</p>

<h1 id="CONSTRUCTOR">CONSTRUCTOR</h1>

<h2 id="new-([-ARGS-])"><a id="new"></a><a id="new---ARGS"></a>new ([ ARGS ])</h2>

<p>Creates a <code>File::Tail</code>. If it has only one paramter, it is assumed to be the filename. If the open fails, the module performs a croak. I am currently looking for a way to set $! and return undef.</p>

<p>You can pass several parameters to new:</p>

<dl>

<dt id="name">name</dt>
<dd>

<p>This is the name of the file to open. The file will be opened for reading. This must be a regular file, not a pipe or a terminal (i.e. it must be seekable).</p>

</dd>
<dt id="maxinterval">maxinterval</dt>
<dd>

<p>The maximum number of seconds (real number) that will be spent sleeping. Default is 60, meaning <code>File::Tail</code> will never spend more than sixty seconds without checking the file.</p>

</dd>
<dt id="interval">interval</dt>
<dd>

<p>The initial number of seconds (real number) that will be spent sleeping, before the file is first checked. Default is ten seconds, meaning <code>File::Tail</code> will sleep for 10 seconds and then determine, how many new lines have appeared in the file.</p>

</dd>
<dt id="adjustafter">adjustafter</dt>
<dd>

<p>The number of <code>times</code> <code>File::Tail</code> waits for the current interval, before adjusting the interval upwards. The default is 10.</p>

</dd>
<dt id="resetafter">resetafter</dt>
<dd>

<p>The number of seconds after last change when <code>File::Tail</code> decides the file may have been closed and reopened. The default is adjustafter*maxinterval.</p>

</dd>
<dt id="maxbuf">maxbuf</dt>
<dd>

<p>The maximum size of the internal buffer. When File::Tail suddenly found an enormous ammount of information in the file (for instance if the retry parameters were set to very infrequent checking and the file was rotated), File::Tail sometimes slurped way too much file into memory. This sets the maximum size of File::Tail&#39;s buffer.</p>

<p>Default value is 16384 (bytes).</p>

<p>A large internal buffer may result in worse performance (as well as increased memory usage), since File::Tail will have to do more work processing the internal buffer.</p>

</dd>
<dt id="nowait">nowait</dt>
<dd>

<p>Does not block on read, but returns an empty string if there is nothing to read. DO NOT USE THIS unless you know what you are doing. If you are using it in a loop, you probably DON&#39;T know what you are doing. If you want to read tails from multiple files, use select.</p>

</dd>
<dt id="ignore_nonexistant">ignore_nonexistant</dt>
<dd>

<pre><code>    Do not complain if the file doesn&#39;t exist when it is first 
opened or when it is to be reopened. (File may be reopened after 
resetafter seconds have passed since last data was found.)</code></pre>

</dd>
<dt id="tail">tail</dt>
<dd>

<pre><code>    When first started, read and return C&lt;n&gt; lines from the file. 
If C&lt;n&gt; is zero, start at the end of file. If C&lt;n&gt; is negative, 
return the whole file.

    Default is C&lt;0&gt;.</code></pre>

</dd>
<dt id="reset_tail">reset_tail</dt>
<dd>

<pre><code>    Same as tail, but applies after reset. (i.e. after the
file has been automaticaly closed and reopened). Defaults to
C&lt;-1&gt;, i.e. does not skip any information present in the
file when it first checks it.

   Why would you want it otherwise? I&#39;ve seen files which
have been cycled like this:

   grep -v lastmonth log &gt;newlog 
   mv log archive/lastmonth 
   mv newlog log 
   kill -HUP logger </code></pre>

<p>Obviously, if this happens and you have reset_tail set to c&lt;-1&gt;, you will suddenly get a whole bunch of lines - lines you already saw. So in this case, reset_tail should probably be set to a small positive number or even <code>0</code>.</p>

</dd>
<dt id="name_changes">name_changes</dt>
<dd>

<p>Some logging systems change the name of the file they are writing to, sometimes to include a date, sometimes a sequence number, sometimes other, even more bizarre changes.</p>

<p>Instead of trying to implement various clever detection methods, File::Tail will call the code reference defined in name_changes. The code reference should return the string which is the new name of the file to try opening.</p>

<p>Note that if the file does not exist, File::Tail will report a fatal error (unless ignore_nonexistant has also been specified).</p>

</dd>
<dt id="debug">debug</dt>
<dd>

<p>Set to nonzero if you want to see more about the inner workings of File::Tail. Otherwise not useful.</p>

</dd>
<dt id="errmode">errmode</dt>
<dd>

<p>Modeled after the methods from Net:Telnet, here you decide how the errors should be handled. The parameter can be a code reference which is called with the error string as a parameter, an array with a code reference as the first parameter and other parameters to be passed to handler subroutine, or one of the words:</p>

<p>return - ignore any error (just put error message in errmsg). warn - output the error message but continue die - display error message and exit</p>

<p>Default is die.</p>

</dd>
</dl>

<h1 id="METHODS">METHODS</h1>

<h2 id="read">read</h2>

<p><code>read</code> returns one line from the input file. If there are no lines ready, it blocks until there are.</p>

<h2 id="select">select</h2>

<p><code>select</code> is intended to enable the programmer to simoultaneously wait for input on normal filehandles and File::Tail filehandles. Of course, you may use it to simply read from more than one File::Tail filehandle at a time.</p>

<p>Basicaly, you call File::Tail::select just as you would normal select, with fields for rbits, wbits and ebits, as well as a timeout, however, you can tack any number of File::Tail objects (not File::Tail filehandles!) to the end.</p>

<p>Usage example:</p>

<pre><code> foreach (@ARGV) {
     push(@files,File::Tail-&gt;new(name=&gt;&quot;$_&quot;,debug=&gt;$debug));
 }
 while (1) {
   ($nfound,$timeleft,@pending)=
             File::Tail::select(undef,undef,undef,$timeout,@files);
   unless ($nfound) {
     # timeout - do something else here, if you need to
   } else {
     foreach (@pending) {
        print $_-&gt;{&quot;input&quot;}.&quot; (&quot;.localtime(time).&quot;) &quot;.$_-&gt;read;
   }
 }

 #
 # There is a more elaborate example in select_demo in the distribution.
 #</code></pre>

<p>When you do this, File::Tail&#39;s select emulates normal select, with two exceptions:</p>

<p>a) it will return if there is input on any of the parameters (i.e. normal filehandles) _or_ File::Tails.</p>

<p>b) In addition to <code>($nfound, $timeleft)</code>, the return array will also contain a list of File::Tail objects which are ready for reading. <code>$nfound</code> will contain the correct number of filehandles to be read (i.e. both normal and File::Tails).</p>

<p>Once select returns, when you want to determine which File::Tail objects have input ready, you can either use the list of objects select returned, or you can check each individual object with $object-&gt;predict. This returns the ammount of time (in fractional seconds) after which the handle expects input. If it returns 0, there is input waiting. There is no guarantee that there will be input waiting after the returned number of seconds has passed. However, File::Tail won&#39;t do any I/O on the file until that time has passed. Note that the value of $timeleft may or may not be correct - that depends on the underlying operating system (and it&#39;s select), so you&#39;re better off NOT relying on it.</p>

<p>Also note, if you are determining which files are ready for input by calling each individual predict, the <code>$nfound</code> value may be invalid, because one or more of File::Tail object may have become ready between the time select has returned and the time when you checked it.</p>

<h1 id="TO-BE-DONE"><a id="TO"></a>TO BE DONE</h1>

<p>Planned for 1.0: Using $/ instead of \n to separate &quot;lines&quot; (which should make it possible to read wtmp type files). Except that I discovered I have no need for that enhancement If you do, feel free to send me the patches and I&#39;ll apply them - if I feel they don&#39;t add too much processing time.</p>

<h1 id="AUTHOR">AUTHOR</h1>

<p>Matija Grabnar, matija.grabnar@arnes.si</p>

<h1 id="SEE-ALSO"><a id="SEE"></a>SEE ALSO</h1>

<p>perl(1), tail (1), MRTG (http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html)</p></div>

<div id="metacpan_install-instructions-dialog" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Module Install Instructions</h4>
      </div>
      <div class="modal-body">
        <p>To install File::Tail, copy and paste the appropriate command in to your terminal.</p>
        <p><a href="https://metacpan.org/dist/App-cpanminus/view/bin/cpanm">cpanm</a></p>
        <pre><code>cpanm File::Tail</code></pre>
        <p><a href="https://metacpan.org/pod/CPAN">CPAN shell</a></p>
        <pre><code>perl -MCPAN -e shell
install File::Tail</code></pre>
        <p>For more information on module installation, please visit <a href="https://www.cpan.org/modules/INSTALL.html">the detailed CPAN module installation guide</a>.</p>
      </div>
      <div class="modal-footer">
        <a href="./File::Tail.html#" data-dismiss="modal" class="btn">Close</a>
      </div>
    </div>
  </div>
</div>
          </main>
          <div class="content-pagination">
          </div>
        </div>
        <footer class="footer">
          <div class="footer-container">
            <div class="footer-social">
              <div class="footer-link footer-logo">
                <a href="https://metacpan.org/">
                  <img src="https://metacpan.org/static/images/metacpan-logo.svg" alt="MetaCPAN" />
                </a>
              </div>
              <a class="footer-social-link" href="https://github.com/metacpan">
                <i class="fab fa-github-square"></i>
              </a>
              <a class="footer-social-link" href="https://fosstodon.org/@metacpan">
                <i class="fab fa-mastodon"></i>
              </a>
            </div>
            <div class="footer-links">
              <div class="footer-link">
                  <a href="https://metacpan.org/about">About</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/sponsors">Sponsor</a>
              </div>
              <div class="footer-link">
                  <a href="https://grep.metacpan.org">grep::cpan</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/recent">Recent</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/faq">FAQ</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/tools">Tools</a>
              </div>
              <div class="footer-link">
                  <a href="https://fastapi.metacpan.org/">API</a>
              </div>
              <div class="footer-link">
                  <a href="https://www.perl.org/">Perl.org</a>
              </div>
            </div>
            <div class="footer-sponsors">
              <a class="footer-sponsor-link" target="_blank" href="https://www.bytemark.co.uk/" rel="noopener">
                <img class="footer-sponsor-bytemark" src="https://metacpan.org/static/images/sponsors/bytemark_logo.svg" alt="Bytemark logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.liquidweb.com/" rel="noopener">
                <img class="footer-sponsor-liquidweb" src="https://metacpan.org/static/images/sponsors/liquidweb_logo.png" alt="liquidweb logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://deriv.com/careers/" rel="noopener">
                <img class="footer-sponsor-deriv" src="https://metacpan.org/static/images/sponsors/deriv.svg" alt="Deriv logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://geocode.xyz" rel="noopener">
                <img class="footer-sponsor-geocode" src="https://metacpan.org/static/images/sponsors/geocodelogo.svg" alt="Geocode logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.fastly.com/" rel="noopener">
                <img class="footer-sponsor-fastly" src="https://metacpan.org/static/images/sponsors/fastly_logo.svg" alt="Fastly logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://opencagedata.com" rel="noopener">
                <img class="footer-sponsor-opencage" src="https://metacpan.org/static/images/sponsors/open-cage.svg" alt="OpenCage logo">
              </a>
            </div>
          </div>
        </footer>
        <div class="modal fade" tabindex="-1" role="dialog" id="metacpan_keyboard-shortcuts">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Keyboard Shortcuts</h4>
              </div>
              <div class="modal-body row">
<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Global</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>s</kbd>
        </td>
        <td>Focus search bar</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>?</kbd>
        </td>
        <td>Bring up this help dialog</td>
      </tr>
    </tbody>
  </table>

  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>GitHub</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>p</kbd>
        </td>
        <td>Go to pull requests</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>go to github issues (only if github is preferred repository)</td>
      </tr>
    </tbody>
  </table>
</div>

<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>POD</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>a</kbd>
        </td>
        <td>Go to author</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>c</kbd>
        </td>
        <td>Go to changes</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>Go to issues</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>d</kbd>
        </td>
        <td>Go to dist</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>r</kbd>
        </td>
        <td>Go to repository/SCM</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>s</kbd>
        </td>
        <td>Go to source</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>b</kbd>
        </td>
        <td>Go to file browse</td>
      </tr>

    </tbody>
  </table>
</div>

<div class="col-md-12">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Search terms</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><em>module:</em> (e.g. <a href="https://metacpan.org/search?q=module%3APlugin">module:Plugin</a>)</td>
      </tr>
      <tr>
        <td><em>distribution:</em> (e.g. <a href="https://metacpan.org/search?q=distribution%3ADancer+auth">distribution:Dancer auth</a>)</td>
      </tr>
      <tr>
        <td><em>author:</em> (e.g. <a href="https://metacpan.org/search?q=author%3ASONGMU+Redis">author:SONGMU Redis</a>)</td>
      </tr>
      <tr>
        <td><em>version:</em> (e.g. <a href="https://metacpan.org/search?q=version%3A1.00">version:1.00</a>)</td>
      </tr>
    </tbody>
  </table>
</div>
              </div>
              <div class="modal-footer"></div>
            </div>
          </div>
        </div>
    </body>
</html>
